import dayjs from 'dayjs'
import relativeTime from 'dayjs/plugin/relativeTime'
import 'dayjs/locale/zh-cn'

dayjs.locale('zh-cn')
dayjs.extend(relativeTime)

export function formatDate (date, template = 'YYYY年MM月DD日') {
  if (!date) {
    return '---'
  }
  return dayjs(new Date(date)).format(template)
}
